package com.bonc.sdk.gofakeit.v1;

import com.bonc.sdk.gofakeit.v1.model.ShowCarRequest;
import com.bonc.sdk.gofakeit.v1.model.ShowCarResponse;
import com.bonc.sdk.core.TypeCasts;
import com.bonc.sdk.core.http.FieldExistence;
import com.bonc.sdk.core.http.HttpMethod;
import com.bonc.sdk.core.http.HttpRequestDef;
import com.bonc.sdk.core.http.LocationType;

@SuppressWarnings("unchecked")
public class FakeItMeta {


    public static final HttpRequestDef<ShowCarRequest, ShowCarResponse> showAppDetail =
            genForShowCar();

    private static HttpRequestDef<ShowCarRequest, ShowCarResponse> genForShowCar() {
        // basic
        HttpRequestDef.Builder<ShowCarRequest, ShowCarResponse> builder =
            HttpRequestDef.builder(HttpMethod.GET, ShowCarRequest.class, ShowCarResponse.class)
                .withName("ShowAppDetail")
                .withUri("/car")
                .withContentType("application/json");

        // requests
        builder.<String>withRequestField("carId",
            LocationType.Query,
            FieldExistence.NON_NULL_NON_EMPTY,
            TypeCasts.uncheckedConversion(String.class),
            f -> f.withMarshaller(ShowCarRequest::getCarId, (req, v) -> {
                req.setCarId(v);
            }));
        builder.<String>withRequestField("gofakeit-instance-id",
            LocationType.Header,
            FieldExistence.NULL_IGNORE,
            TypeCasts.uncheckedConversion(String.class),
            f -> f.withMarshaller(ShowCarRequest::getGoFakeItInstanceId, (req, v) -> {
                req.setGoFakeItInstanceId(v);
            }));

        // response

        return builder.build();
    }


}
